package javaParser;
/*
 * RdfVariableList.java
 *
 * Created on February 26, 2008, 12:40 PM
 *
 */

/**
 *
 * @author Tian, Juan
 */
import java.util.LinkedList;
public class RdfVariableList {
    LinkedList<RdfVariable> list = new LinkedList<RdfVariable> ();
    /** Creates a new instance of RdfVariableList */
    public RdfVariableList() {
    }
    public int size() {
        return list.size();
    }
    public void remove(int i) {
        list.remove(i);
    }
 
    public boolean deleteVariables (int level) {
        for( int i=0; i< size(); i++)
        {
            while(i < size() && (get(i)).getLevel() >= level) {
                remove(i);
            } 
        }
        return true;
    }
    public RdfVariable get(int i) {
        return list.get(i);
    }
    public boolean remove(RdfVariable a) {
        return list.remove(a);
    }
 
    public RdfVariable getVariable(int level, String name) {
        for(int j = level; j >= 0; j --) {
        	for( int i=0; i< size(); i++){
	            if(get(i).getLevel() >= j && get(i).getName().equals(name)) {
	            	return get(i);
	            }    
        	}
        }        
        return null;
    }
    public boolean addVariable(RdfVariable a){
        return list.add(a);
    }
}
